var $ = require("../../utils/Ajax.js");
var WxParse = require('../../utils/wxParse/wxParse.js');
Page({
  data: {
    PictureUrl: getApp().PictureUrl,
    // 转卖信息
    StoreTeaDetails: null
  },

  onLoad: function (options) {
    var that = this;
    wx.setNavigationBarTitle({
      title: "转卖详情"
    }) 
    $.Ajax("api/goods","GET",{
      teaId: options.Id,
      id: options.GoodsId,
      s: 1
    },function(res){
      if (res.s) {
        WxParse.wxParse('article', 'html', res.d.goods.details, that, 0);
        that.setData({
          StoreTeaDetails: res.d.goods
        })
      }else{
        wx.showToast({
          title: res.m,
          icon: 'success',
          duration: 1500
        })
        setTimeout(function(){
          wx.navigateBack({
            datail: 1
          })
        },1500)
      }
    })
  },

  onShow: function () {

  },

  // 点击查看资料
  Data: function(e){
    var Id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../Data/Data?Id=' + Id,
    })
  },

  // 立即购买
  StoreTea: function(e){
    var Id = e.currentTarget.dataset.id;
    $.Ajax("api/BuyTea","POST",{
      id: Id
    },function(res){
      var BuyInfor = JSON.stringify(res.d);
      if(res.s){
        wx.navigateTo({
          url: '../SubmitTea/SubmitTea?BuyInfor=' + BuyInfor,
        })
      }
    })
  }
})